/*
 * p3551.cpp
 *
 *  Created on: 2013-5-31
 *      Author: zy
 */

#include<cstdio>

double E, p, p1;
int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		long long n;
		E = 0.0;
		scanf("%lld%lf", &n, &p);
		for (int i = n - 1; i >= 1; i--)
		{
			p1 = 2.0 * i * (n - i) / (n * (n - 1)) * p;
			E = E + 1.0 / p1;
		}
		printf("%0.3lf\n", E);
	}
	return 0;
}
